package com.ruoyi.notify.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.notify.domain.BackendOrderNotify;
import com.ruoyi.notify.service.IBackendOrderNotifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 订单通知Controller
 *
 * @author ruoyi
 * @date 2025-04-19
 */
@RestController
@RequestMapping("/backendOrderNotify/backendOrderNotify")
public class BackendOrderNotifyController extends BaseController {
    @Autowired
    private IBackendOrderNotifyService backendOrderNotifyService;

    /**
     * 查询订单通知列表
     */
    @PreAuthorize("@ss.hasPermi('backendOrderNotify:backendOrderNotify:list')")
    @GetMapping("/list")
    public TableDataInfo list(BackendOrderNotify backendOrderNotify) {
        startPage();
        List<BackendOrderNotify> list = backendOrderNotifyService.selectBackendOrderNotifyList(backendOrderNotify);
        return getDataTable(list);
    }

    /**
     * 导出订单通知列表
     */
    @PreAuthorize("@ss.hasPermi('backendOrderNotify:backendOrderNotify:export')")
    @Log(title = "订单通知", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BackendOrderNotify backendOrderNotify) {
        List<BackendOrderNotify> list = backendOrderNotifyService.selectBackendOrderNotifyList(backendOrderNotify);
        ExcelUtil<BackendOrderNotify> util = new ExcelUtil<BackendOrderNotify>(BackendOrderNotify.class);
        util.exportExcel(response, list, "订单通知数据");
    }

    /**
     * 获取订单通知详细信息
     */
    @PreAuthorize("@ss.hasPermi('backendOrderNotify:backendOrderNotify:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(backendOrderNotifyService.selectBackendOrderNotifyById(id));
    }

    /**
     * 新增订单通知
     */
    @PreAuthorize("@ss.hasPermi('backendOrderNotify:backendOrderNotify:add')")
    @Log(title = "订单通知", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BackendOrderNotify backendOrderNotify) {
        return toAjax(backendOrderNotifyService.insertBackendOrderNotify(backendOrderNotify));
    }

    /**
     * 修改订单通知
     */
    @PreAuthorize("@ss.hasPermi('backendOrderNotify:backendOrderNotify:edit')")
    @Log(title = "订单通知", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BackendOrderNotify backendOrderNotify) {
        return toAjax(backendOrderNotifyService.updateBackendOrderNotify(backendOrderNotify));
    }

    /**
     * 删除订单通知
     */
    @PreAuthorize("@ss.hasPermi('backendOrderNotify:backendOrderNotify:remove')")
    @Log(title = "订单通知", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(backendOrderNotifyService.deleteBackendOrderNotifyByIds(ids));
    }
}
